$(function(){
    var elmMsg    = $('#message');
    var fields    = $('#email, #senha');
    var btnLogin  = $('#btnLogin');
    var btnCancel = $('#btnCancel');
    
    $('input:first').focus();
    
    btnLogin.click(function()
    {   
        if ($('#formLogin').valid())
            App.formLogin('#formLogin');
    }); 
    
    fields.keypress(function(e){
        if (e.which == 13) 
        {
            btnLogin.click();
        }
    });
    
    btnCancel.click(function()
    {       
        App.pageRefresh();
    }); 
    
    $('#formLogin').validate({
        rules: {
            email: {
                required: true,
                email: true
            },
            senha: {
                required: true
            }
        },
        messages: {
            email: {
                required: " Informe o email.",
                email: " Informe um email v&aacute;lido."
            },
            senha: {
                required: " Informe a senha."
            }
        }
    });      
});